import request from '@/utils/request'

/**
 * 微信公众号接口服务
 * @type {{saveWeChatMp: (function(*=): *), getWeChatMpList: (function(*): *), editWeChatMp: (function(*=): *), deleteWeChatMp: (function(*): *)}}
 */
export const MpService = {
  // 微信公众列表
  getWeChatMpList: function(params) { return request({ method: 'get', url: '/manage/wechat/mp/list.do', params: { ...params }}) },
  // 所有微信公众列表
  getWeChatMpAll: function() { return request({ method: 'get', url: '/manage/wechat/mp/all.do' }) },
  // 保存微信公众号信息
  saveWeChatMp: function(config) { return request({ method: 'post', url: '/manage/wechat/mp/add.do', data: config }) },
  // 编辑微信公众号信息
  editWeChatMp: function(config) { return request({ method: 'post', url: '/manage/wechat/mp/edit.do', data: config }) },
  // 删除微信公众号信息
  deleteWeChatMp: function(id) { return request({ method: 'post', url: '/manage/wechat/mp/delete.do', data: [id] }) }
}

/**
 * 微信公众号自定义菜单
 * @type {{pushMenu: (function(*): *), getMenus: (function(*): *), addMenu: (function(*=): *)}}
 */
export const MpMenuService = {
  // 添加菜单
  addMenu: function(data) { return request({ method: 'post', url: '/manage/wechat/mp/menu/merge.do', data: data }) },
  // 获得菜单
  getMenus: function(query) { return request({ method: 'get', url: '/manage/wechat/mp/menu/list.do', params: { ...query }}) },
  // 发布菜单
  pushMenu: function(query) { return request({ method: 'get', url: '/manage/wechat/mp/menu/push.do', params: { ...query }}) }
}

/**
 * 微信公众号素材
 * @type {{getMaterials: (function(*): *), uploadMaterials: (function(*): *)}}
 */
export const MpMaterialService = {
  // 素材列表
  getMaterials: function(query) { return request({ method: 'get', url: '/manage/wechat/mp/material/list.do', params: { ...query }}) },
  // 获取图文素材详情
  getNewsMaterialInfo: function(query) { return request({ method: 'get', url: '/manage/wechat/mp/material/news/info.do', params: { ...query }}) },
  // 上传素材
  uploadMaterials: function(data) { return request({ method: 'post', url: '/manage/wechat/mp/material/add.do', data: data }) },
  // 编辑素材
  editMaterials: function(data) { return request({ method: 'post', url: '/manage/wechat/mp/material/edit.do', data: data }) },
  // 删除微信公众号素材
  deleteMaterial: function(query) { return request({ method: 'post', url: '/manage/wechat/mp/material/delete.do', params: { ...query }}) },
  // 获得视频信息
  getVideoMaterialInfo: function(query) { return request({ method: 'get', url: '/manage/wechat/mp/material/stream.do', params: { ...query }}) }
}
